﻿using System.Collections;
using System.Collections.Generic;
using Framework.Utilities;
using UnityEngine;
using UnityEngine.UI;

namespace App.Common
{
    /// <summary>
    /// 本地化的辅助组件，用于挂在文本上进行自动赋值，使用物体名称作为Key
    /// </summary>
    public class LocalizationHelper : MonoBehaviour
    {
        /// <summary>
        /// 是否每一帧都检查，如果不存在使用中改变语言的情况则不必要开启。
        /// </summary>
        public bool CheckPerFrame;

        private void Awake()
        {
            GetComponent<Text>().text = Localization.Instance.GetText(gameObject.name);
        }

        private void Update()
        {
            if (CheckPerFrame)
            {
                GetComponent<Text>().text = Localization.Instance.GetText(gameObject.name);
            }
        }
    }
}